#!/bin/bash

DIRECTORY="$(dirname "$(dirname "$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")")"

function error {
  echo -e "\\e[91m$1\\e[39m"
  exit 1
}

rm -rf ~/PiGro-Aid- || error "Failed to first remove ~/PiGro-Aid- folder!"
git clone https://github.com/actionschnitzel/PiGro-Aid- || error "Failed to clone repository!"

# Get dependencies
"${DIRECTORY}/pkg-install" "neofetch" "$(dirname "$0")" || exit 1

cd PiGro-Aid- || error "Failed to enter directory!"

pip3 install playsound

chmod +x install.sh
chmod +x start.sh
chmod +x scripts/raspiconfiginstall.sh
chmod +x scripts/autoremove.sh
chmod +x scripts/addunsignedrepo.sh
chmod +x scripts/update.sh
chmod +x scripts/upgrade.sh
chmod +x scripts/lxappearance.sh
chmod +x scripts/rmlxde.sh
chmod +x scripts/terminal.sh
chmod +x scripts/xfce4fix.sh
chmod +x scripts/uninstall.sh
chmod +x scripts/fmsudo.sh
chmod +x scripts/pi-apps.sh
chmod +x scripts/ov_2.sh
chmod +x scripts/ov_1.sh
cp pigro.desktop  ~/Desktop
cp pigro.desktop ~/.local/share/applications/
